import {defineStore} from 'pinia'
import {getEmployeeApi} from "@/api/Select";

export const usePAUserTwoStore = defineStore('PAUserTwo', {
    state: () => {
        return {
            tabledata: []
        }
    },
    getters: {},
    actions: {
        setTableData(tabledata) {
            this.tabledata.push(tabledata)
        },
        getTableData() {
            this.tabledata = []
            getEmployeeApi().then(res => {
                for (let i = 0; i < res['data'].length; i++) {
                    this.tabledata.push({
                        id: res['data'][i].userId,
                        name: res['data'][i].userName,
                        position: "雇员",
                        status: res['data'][i].statusId,
                        isDisabled: false
                    })
                }
            })
        },
        deleteUser(tabledata) {
            // 表示先获取这个元素的下标，然后从这个下标开始计算，删除长度为1的元素
            this.tabledata.splice(this.tabledata.indexOf(tabledata), 1)
        }
    }

})
